<script setup lang="ts">
onMounted(() => {
  console.log('子组件')
})

// 获取屏幕安全区域
const { safeAreaInsets } = uni.getSystemInfoSync()
const back = () => {
  uni.navigateBack()
}

// 添加小组
const showAddGroup = () => {
  uni.navigateTo({ url: '/pages/group/group' })
}

// 加入小组
const showJoinGroup = () => {
  uni.navigateTo({ url: '/pages/group/join' })
}
</script>

<template>
  <view class="navbar" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
    <!-- <view class="logo">
      <image class="logo-image" src="@/static/images/logo.png" />
      <text class="logo-text">新鲜 亲民 快捷</text>
    </view> -->
    <view class="back" @tap="back"><uni-icons type="left" size="20" /></view>

    <view class="title">
      <!-- <text>我的小组</text> -->
      <!-- <view class="add"><uni-icons type="plusempty" size="15" /></view> -->
      <button class="mini-btn create-btn" @tap="showJoinGroup" size="mini">加入</button>
      <button class="mini-btn create-btn" @tap="showAddGroup" size="mini">建组</button>
    </view>
  </view>
</template>

<style lang="scss">
.navbar {
  position: relative;
  display: flex;
  flex-direction: row;

  // #ifdef
  justify-content: start;
  height: 100rpx;
  padding: 30px 0 0 70rpx;
  padding-top: 20px;
  background-image: url(@/static/home/navigator_bg.png);
  // background-color: #90D7EC;
  background-size: cover;
  // #endif

  .logo {
    display: flex;
    align-items: center;
    height: 64rpx;
    padding-left: 30rpx;

    .logo-image {
      width: 166rpx;
      height: 39rpx;
    }

    .logo-text {
      flex: 1;
      padding-left: 20rpx;
      margin: 2rpx 0 0 20rpx;
      font-size: 26rpx;
      line-height: 28rpx;
      color: #fff;
      border-left: 1rpx solid #fff;
    }
  }

  .title {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70%;
    height: 64rpx;
    padding: 0 10rpx 0 0rpx;
    margin: 16rpx 0;
    font-size: 33rpx;
    color: black;

    .add {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 40rpx;
      height: 40rpx;
      padding: 0 10rpx 0 26rpx;
      margin: 25rpx 20rpx;
      font-size: 28rpx;
      color: #fff;
      background-color: $aider-color-low;
      border-radius: 50%;
    }

    .create-btn {
      margin: 25rpx 20rpx;
      font-size: 28rpx;
      background-color: $aider-color-low;
      border-color: $aider-color-low;
      border-radius: 20rpx;
    }
  }

  .back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64rpx;
    height: 64rpx;
    padding: 0 10rpx 0 0;
    margin: 16rpx 10rpx;
    font-size: 28rpx;
    color: #fff;
  }

  .icon-search {
    color: black;
    &::before {
      margin-right: 10rpx;
    }
  }

  .icon-scan {
    padding: 15rpx;
    font-size: 30rpx;
  }
}
</style>
